<?php include('header.php');?>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span 12">
			<h1>ADMIN</h1>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span2"">
			<?php include('lefter.php');?>
		</div>
		<div class="span10">
			<div class="row-fluid">
				<div class="span8">
					<h3>
						<span>CAREERS</span>
					</h3>
				</div>
			</div>
			<hr />
			<div class="work-view-count">
				<h5>구인팝업 활성화 </h5>
				<div class="btn-group" data-toggle="buttons-radio">
					<button type="button" class="btn select-on-off <?php if($careers_view_count == '1') :?>active<?php endif;?>" data-value="1">on</button>
					<button type="button" class="btn select-on-off <?php if($careers_view_count == '0') :?>active<?php endif;?>" data-value="0">off</button>
				</div>
			</div>
			<div class="ul-table careers">
				<ul class="header">
					<li class="no">NO</li>
					<li class="date hidden-phone">DATE</li>
					<li class="title">TITLE</li>
					<li class="view">VIEW</li>
					<li class="delete">DELETE</li>
				</ul>
			</div>
			<div class="ul-table ul-table-body careers">
			<?php foreach($careers_rows as $row) :?>
				<ul>
					<li class="no"><?=$row['id']?></li>
					<li class="date hidden-phone"><?=date('Y.m.d', strtotime($row['register_date']))?></li>
					<li class="title"><a href="<?=base_url('admin/careers_edit/'.$row['id'])?>"><?=$row['title']?></a></li>
					<li class="view"><input type="radio" name="view" class="radio-view" <?php if($row['view'] == 'show') :?>checked<?php endif;?>></li>
					<li class="delete"><button type="button" class="btn btn-small btn-danger btn-delete">Delete</button></li>
				</ul>
			<?php endforeach;?>
			</div>
			<div class="row-fluid">
				<div class="span4 offset8">
					<div class="pull-right">
						<button type="button" class="btn btn-primary btn-write">Write</button>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="<?=JS_DIR?>/jquery-1.8.3.min.js"></script>
<script src="<?=JS_DIR?>/respond.min.js"></script>
<script src="<?=JU_DIR?>/js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="<?=BS_DIR?>/admin/js/bootstrap.min.js"></script>

<script>
$(function() {
	$("button.btn-write").click(function() {
		location.href = "<?=base_url('admin/careers_write')?>";
	});
	$("input.radio-view").click(function() {
		var id = $(this).parent().parent().children("li.no").text();
		$.ajax({
			type: 'post',
			url: "<?=base_url('admin/careers_view_action')?>",
			data: { 
				id: id
			},
			success: function(data){
				//alert('View saved!');
			},
			error: function(jqXHR, textStatus, errorThrown){
				alert( errorThrown );
			}
		});
	});
	$("button.btn-delete").click(function() {
		if(confirm('Delete?')) {
			var id = $(this).parent().parent().children("li.no").text();
			$.ajax({
				type: 'post',
				url: "<?=base_url('admin/careers_delete_action')?>",
				data: { 
					id: id
				},
				success: function(data){
					location.href = "<?=base_url('admin/careers')?>";
				},
				error: function(jqXHR, textStatus, errorThrown){
					alert( errorThrown );
				}
			});
		}
	});
	$("button.select-on-off").on('click', function() {
		$.ajax({
			type: 'post',
			url: "<?=base_url('admin/view_count_action')?>",
			data: { 
				mode: 'careers',
				count: $(this).attr("data-value")
			},
			success: function(data){
				alert('View saved!');
			},
			error: function(jqXHR, textStatus, errorThrown){
				alert( errorThrown );
			}
		});
	});
});
</script>
<?php include('footer.php');?>